package sdl_impl

import (
	"code.google.com/p/go8/display"
	"github.com/banthar/Go-SDL/sdl"
)

type Image struct {
	screen  *sdl.Surface
	surface *sdl.Surface
}

func NewImage(scr, surf *sdl.Surface) *Image {
	return &Image{screen: scr, surface: surf}
}

func (i *Image) Size() (w, h int) {
	return int(i.surface.W), int(i.surface.H)
}

func (i *Image) DrawAt(pos display.Rect) {
	i.screen.Blit(toSdlRect(pos), i.surface, nil)
}

func toSdlRect(r display.Rect) *sdl.Rect {
	return &sdl.Rect{int16(r.X), int16(r.Y), uint16(r.W), uint16(r.H)}
}
